<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <table border="1">
        <caption>员工列表</caption>
        <tr>
            <th>id</th>
            <th>名字</th>
            <th>工资</th>
            <th>工作</th>
            <th>操作</th>
        </tr>
        <tr v-for="emp in arr">
            <td>{{emp.id}}</td>
            <td>{{emp.name}}</td>
            <td>{{emp.salary}}</td>
            <td>{{emp.job}}</td>
            <td>
                <a :href="'/update.html?id='+emp.id">修改</a>
                <a href="javascript:void(0) "@click="dal(emp.id)">删除</a>
            </td>
        </tr>
    </table>
</div>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script>
    let v= new Vue({
        el:"body>div",
        data:{
            arr:[]
        },
        //created:
        created:function (){
            axios.get("/select").then(function (response){
                v.arr = response.data;
            })
        },
        methods:{
            dal(id){
                axios.get("/delete?id="+id).then(function (){
                    alert("删除成功!");
                    location.reload();
                })
            }
        }
    })
</script>
</body>
</html>